package com.jlz.beans.user;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.jlz.beans.def.DivisionBean;
import com.jlz.managers.def.Divisions;
import com.jlz.managers.user.Links;
import com.julewa.User;
import com.julewa.db.DB;
import com.julewa.db.Entity;

/*
 * 用来处理登录的信息
 * 包含了关键的用户名/密码/类型/状态信息
 * 
 * 一个人允许用邮件或者手机号码作为账户名登录
 */

@DB.USECACHE
@Component @Scope(Entity.SCOPE)
public class UserBean extends Entity<Long> implements User{
	private @Autowired Divisions divisions = null;
	private @Autowired Links linksrv = null;
	
	@DB.COLUMN String name;//显示用的名 
	
	//
	@DB.COLUMN int type;//用户类型,普通,VIP,通常这跟权限相关
	@DB.COLUMN int state;//状态,新建,确认,活跃,沉默

	//
	@DB.COLUMN int birthDay;
	@DB.COLUMN long registerDate;
	@DB.COLUMN long loginDate;

	//
	@DB.COLUMN long locationId;
	@DB.COLUMN String address = null;

	//
	@DB.COLUMN String account = null;
	@DB.COLUMN String description = null;

	//
	DivisionBean location = null;
	List<LinkBean> links = null;
	//
	public DivisionBean getLocation() {
		if(location == null && this.locationId > 0){
			location = divisions.getDivision(this.locationId);
		}
		return location;
	}
	public void setLocation(DivisionBean location) {
		this.location = location;
	}
	public List<LinkBean> getLinks() {
		if(links == null){
			links = linksrv.getLinksOf(this);
		}
		return links;
	}
	public void setLinks(List<LinkBean> links) {
		this.links = links;
	}
	//
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	//all normal user type greate than 0
	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public int getState() {
		return state;
	}
	public void setState(int state) {
		this.state = state;
	}
	public int getBirthDay() {
		return birthDay;
	}
	public void setBirthDay(int birthDay) {
		this.birthDay = birthDay;
	}
	public long getRegisterDate() {
		return registerDate;
	}
	public void setRegisterDate(long registerDate) {
		this.registerDate = registerDate;
	}
	public long getLoginDate() {
		return loginDate;
	}
	public void setLoginDate(long loginDate) {
		this.loginDate = loginDate;
	}
	public long getLocationId() {
		return locationId;
	}
	public void setLocationId(long locationId) {
		this.locationId = locationId;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getAccount() {
		return account;
	}
	public void setAccount(String account) {
		this.account = account;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	
	
}
